package com.gxa.controller;

import com.gxa.common.JsonResult;
import com.gxa.common.PageRecv;
import com.gxa.common.R;

import com.gxa.pojo.Documentary;
import com.gxa.service.DocumentaryService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;


/**
 * Created with IntelliJ IDEA.
 * User: 张剑宇
 * Date: 2021/12/01 18:22
 * Description:
 * Version: V1.0
 */
@Controller
@Api(value = "数据test",tags = "跟单管理数据接口API-张剑宇")

@RequestMapping("/documentary")
public class DocumentaryController {

    @Autowired(required = false)
    private DocumentaryService documentaryService;

     //1.跟单页面查询
    @RequestMapping(value = "/findDocumentaryList",method = RequestMethod.POST)
    @ApiOperation(value = "跟单查询接口",notes = "传递当前页码数和每页显示记录数和查询实体对象",httpMethod = "POST", response = JsonResult.class)

    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏请求"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=405,message="Method请求错误"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public JsonResult findDocumentaryList(@RequestBody @ApiParam(name = "pageRecv",value = "页面实体",required = true)PageRecv<Documentary> pageRecv){
        JsonResult<Documentary> r=documentaryService.findDocumentaryList(pageRecv);

         return r;
     }
    //2.跟单主页面搜索
    @RequestMapping(value = "/searchDocumentaryList",method = RequestMethod.POST)
    @ApiOperation(value = "跟单搜索接口",notes = "传递当前页码数和每页显示记录数和条件",httpMethod = "POST", response = JsonResult.class)
    @ApiImplicitParams({

            @ApiImplicitParam(name = "condition",value = "想要删除跟单数据的条件",dataType = "String",paramType = "query",required = true),
            @ApiImplicitParam(name = "pageSize",value = "页面数量",dataType = "Integer",paramType = "query",required = true),
            @ApiImplicitParam(name = "currentPage",value = "当前页数",dataType = "Integer",paramType = "query",required = true),
            @ApiImplicitParam(name = "employee_name",value = "跟单人",dataType = "String",paramType = "query",required = true),
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏请求"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=405,message="Method请求错误"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public JsonResult searchDocumentaryList(@RequestParam (name = "condition",required = true)String condition,@RequestParam (name = "pageSize",required = true)Integer pageSize,@RequestParam (name = "currentPage",required = true)Integer currentPage,@RequestParam (name = "employee_name",required = true)String employee_name){

        JsonResult<Documentary> r=documentaryService.searchDocumentaryList(condition,pageSize,currentPage,employee_name);

        return r;
    }
    //2.跟单主页面高级搜索
    @RequestMapping(value = "/searchDocumentaryListByCondition",method = RequestMethod.POST)
    @ApiOperation(value = "跟单搜索接口",notes = "传递当前页码数和每页显示记录数和搜索条件对象",httpMethod = "POST", response = JsonResult.class)

    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏请求"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=405,message="Method请求错误"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public JsonResult searchDocumentaryListByCondition(@RequestBody @ApiParam(name = "pageRecv",value = "页面实体",required = true)PageRecv<Documentary> pageRecv){

        JsonResult<Documentary> r=documentaryService.searchDocumentaryListByCondition(pageRecv);

        return r;
    }

    //4.跟单数据删除 通过documentary_id
    @RequestMapping(value = "/deleteDocumentary",method = RequestMethod.POST)
    @ApiOperation(value = "跟单数据删除接口",notes = "传递想要删除跟单数据的id",httpMethod = "POST", response = R.class)
    @ApiImplicitParams({

            @ApiImplicitParam(name = "documentary_id",value = "想要删除跟单数据的id",dataType = "Integer",paramType = "query",required = true),

    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏请求"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=405,message="Method请求错误"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R deleteDocumentary(@RequestParam(name = "documentary_id",required = true) Integer documentary_id){
       R r=documentaryService.deleteDocumentary(documentary_id);

        return r;
    }


    //5.跟单数据添加
    @RequestMapping(value = "/addDocumentary",method = RequestMethod.POST)
    @ApiOperation(value = "增加跟单数据接口",notes = "跟单数据实体json格式",httpMethod = "POST", response = R.class)

    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏请求"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=405,message="Method请求错误"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R addDocumentary(@RequestBody @ApiParam(name = "documentary",value = "跟单数据实体",required = true) Documentary documentary ){
        R r=documentaryService.addDocumentary(documentary);


        return r;
    }

    //6.跟单数据修改
    @RequestMapping(value = "/updateDocumentary",method = RequestMethod.POST)
    @ApiOperation(value = "修改跟单数据接口",notes = "跟单数据实体json格式",httpMethod = "POST", response = R.class)

    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏请求"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=405,message="Method请求错误"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R updateDocumentary(@RequestBody @ApiParam(name = "documentary",value = "跟单数据实体",required = true) Documentary documentary ){
        R r=documentaryService.updateDocumentary(documentary);

        return r;
    }

    //7.跟单数据统计（按员工）
    @RequestMapping(value = "/countDocumentaryByEmployee",method = RequestMethod.POST)
    @ApiOperation(value = "通过员工统计跟单数据",notes = "通过员工统计跟单数据",httpMethod = "POST", response = R.class)
    @ResponseBody
    public R countDocumentaryByEmployee(@RequestParam (name = "start_time",required = true)String start_time,@RequestParam (name = "stop_time",required = true)String stop_time){
        R r=documentaryService.countDocumentaryByEmployee(start_time,stop_time);

        return r;
    }

    //7.跟单数据统计（按部门）
    @RequestMapping(value = "/countDocumentaryByDept",method = RequestMethod.POST)
    @ApiOperation(value = "通过员工统计跟单数据",notes = "通过部门统计跟单数据",httpMethod = "POST", response = R.class)
    @ApiImplicitParams({

            @ApiImplicitParam(name = "start_time",value = "开始时间",dataType = "String",paramType = "query",required = true),
            @ApiImplicitParam(name = "stop_time",value = "结束时间",dataType = "String",paramType = "query",required = true),

    })
    @ResponseBody
    public R countDocumentaryByDept(@RequestParam (name = "start_time",required = true)String start_time,@RequestParam (name = "stop_time",required = true)String stop_time){
        R r=documentaryService.countDocumentaryByDept(start_time,stop_time);

        return r;
    }



}
